package com.cljz.peipei.model.dao;


import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Schema;

/**
 * Created by apple on 2017/4/5.
 */

public class DaoExample {
    public static void main(String[] args) throws Exception {

        int version = 1;
        String defaultPackage = "com.clzj.peipei.bean";
        //创建模式对象，指定版本号和自动生成的bean对象的包名
        Schema schema = new Schema(version, defaultPackage);

        //指定自动生成的dao对象的包名,不指定则都DAO类生成在defaultPackage包中
        schema.setDefaultJavaPackageDao("com.clzj.peipei.dao");

        addNote(schema);

        //自动生成的bean和dao存放的java-gen路径，注意要改成自己的
        String outDir = "././app/src/main/java-gen";
        new DaoGenerator().generateAll(schema, outDir);
    }

    private static void addNote(Schema schema) {
        Entity userInfo = schema.addEntity("UserInfo");
        userInfo.addStringProperty("nickname");
        userInfo.addStringProperty("token").notNull().primaryKey();
        userInfo.addStringProperty("birthday");
        userInfo.addStringProperty("sex");
        userInfo.addStringProperty("user_id").notNull();
        userInfo.addStringProperty("download");
    }
}
